package com.jj.message;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public enum ProtoFormat {
    Standard((byte)1),
    ProtoBuf((byte)2),
    JSON((byte)3),
    Request((byte)4),
    Response((byte)5),
    Heartbeat((byte)0),
    Internal((byte)127);

    private static Logger logger = LoggerFactory.getLogger(ProtoFormat.class);
    private byte value;
    ProtoFormat(byte value){
        this.value = value;
    }
    public byte getValue(){
        return value;
    }
    public static ProtoFormat findByValue(byte value){
        switch (value){
            case 0:
                return Heartbeat;
            case 1:
                return Standard;
            case 2:
                return ProtoBuf;
            case 3:
                return JSON;
            case 4:
                return Request;
            case 5:
                return Response;
            case 127:
                return Internal;
            default:
                logger.error("unknown value:{}", value);
                return null;
        }
    }
}
